<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>组件配置配置-combo</title>
<{$showjs}>
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<script language="javascript">
Ext.onReady(function(){
var myMask = new Ext.LoadMask(Ext.getBody(), {
                        msg: '请稍候...',
                        removeMask: true //完成后移除
                    });
var store = new Ext.data.SimpleStore({
						fields:['name','value'],
						data:[<{$items}>]
						});
var combobox = new Ext.form.ComboBox({
						id : 'combobox',
						name : 'combo',
						height: 150,
						width:200,
						fieldLabel : '静态下拉',
						hiddenName : 'combo',
						//data:store.data,
						value:'<{$ck}>',
						store:store,
						mode:'local',
				        displayField:'name',
				        valueField :'value',
				        triggerAction:"all",
				        listeners: {
				        	"select":{
				            	fn: function(_combo,store,index){
				            		_combo["selectItem"]=store;
				            		var label_ = store.data.name;
				            		var value_ = store.data.value;
				            		Ext.getCmp('label').setValue(label_);
				            		Ext.getCmp('value').setValue(value_);
				            	},
				                scope: this
				            }
				        }
					});

var form = new Ext.TabPanel({

		activeTab: 0,
//		height:parent.Ext.get('t<{$fld.id}>').getHeight()-36,
		height:parent.Ext.get('t<{$fld.id}>').getHeight()-36,
		region     : 'center',
		title      : false,
		border	   : false,
		frame	   : true,
		defaults:{bodyStyle:'padding:10px'},
		items      : [{
				title:'静态下拉',
                layout:'column',
                bbar:['->','-',{
			            text: '添加',
			            handler:function(){
			            	myMask.show();
								var DATA=Ext.data.Record.create([{
								name:"name",value:"value"}
								]);
								var label_ = Ext.getCmp('label').getValue();
								var value_ = Ext.getCmp('value').getValue();
								store.insert(0,new DATA({name:label_,value:value_}));
								combobox.setValue(label_);
								store["selectItem"]=store.getAt(0);
							myMask.hide();
						}
			        }//,'-',{
			           // text: '修改',
			           // handler:function(){
			          //  	myMask.show();
			          //  		var label_ = Ext.getCmp('label').getValue();
					//			var value_ = Ext.getCmp('value').getValue();
					//			if(combobox["selectItem"]!=null){
					//					combobox["selectItem"].set("value",value_);
					//					combobox.setValue(label_);
					//			}else{
					//				Ext.Msg.alert('提示','请先选择一个！');
					//			}
					//		myMask.hide();
					//	}
					//	}
						,'-',{
			            text: '删除',
			            handler:function(){
							if(combobox["selectItem"]!=null)
								Ext.MessageBox.confirm("系统提示","你确认删除当前项目吗?",function(_btn){
									if(_btn=="yes"){
										try{store.remove(combobox["selectItem"]);}catch(_err){}
											if(store.getCount()){
												combobox.setValue(store.getAt(0).get("value"));
												combobox["selectItem"]=store.getAt(0);
											}else{
												combobox.setValue('');
												combobox["selectItem"]=null;
											}
										}
									});
							}

			        },'-'],
                items:[{
                	border:false,
           			columnWidth:.5,
           			autoHeight: true,
           			layout:'column',
           			bodyStyle:'padding:10px',
                	items:[
                	{
                		xtype: 'label',
                		text: '标签',
                		cls:'x-form-check-group-label',
                		anchor:'-15'
                	},{
						xtype: 'textfield',
						id:'label',
                        name: 'label',value:'<{$xv}>' 
                    }]
                },{
                	border:false,
           			columnWidth:.5,
           			autoHeight: true,
           			bodyStyle:'padding:10px',
           			layout:'column',
                	items:[{
                		xtype: 'label',
                		text: '值',
                		cls:'x-form-check-group-label',
                		anchor:'-15'
                	},{
						xtype: 'textfield',
						id:'value',
                        name: 'value',value:'<{$ck}>'                  }]
                	},{
                	xtype:'fieldset',
                	title:'配置',
           			columnWidth:1,
           			autoHeight: true,
           			bodyStyle:'padding:10px',
           			layout:'form',
                	items:[combobox]
                	}]

		}],
		 buttons: [{
            text: '保存',
            handler:function(){
            	var  x = '';
            	Ext.each(combobox.store.data.items,function(a,b,c){
					
					x = x  + a.data.name+'#_#'+a.data.value+ '#=#';
            	});
            	myMask.show();
            	Ext.Ajax.request({
			        waitMsg:'正在提交....',
			        method:'POST',
			        params:{op:'save',type:'combovalue',param:x,id:'<{$fld.id}>',ck:Ext.getCmp('combobox').getValue()},
			        url:'fldcfg.php',
			        success:function(form, action) {
			             myMask.hide();
			             parent.Ext.getCmp('t<{$fld.id}>').close();
			        },
			        failure: function(form, action) {
			        }
			     });
            }
        },{
            text: '重置'
        }]


});
var tabpanel = new Ext.form.FormPanel({
		renderTo: Ext.getBody(),
        //frame:true,
		//defaults:{autoScroll: true},
		items:[
			form
		]
});
});
</script>
</head>
<body>
</body>
</html>